<?php

namespace goosh;

function checkinstall()

{
  $ini=goosh_base."/goosh.ini";

  if(!is_dir(goosh_base) || !file_exists($ini))
  
  {
    println('It seems this is the first time you use goosh as '.$user.'. goosh will install itself now.');
    
    if(!is_dir($base) && !mkdir($base))
    throw new gooshException('could not create goosh directory');
    
    if(!is_int($fs=file_put_contents($ini,<<<INI
key='AIzaSyBepS8WH14tbifWtjIg5cUZVXLiY_1xfuQ'
key2='ABQIAAAAvdh5Eiok66W-COwX8K1JzRT8qwNHx01vrZG8_BHkz5Y4UJat8RRyWC93UhBQFO8rhfJ-9PMNFIRVGA'
cx='012956011926541165428:ppbxvzvibn8'
url='https://www.googleapis.com/customsearch/v1'
url2='https://ajax.googleapis.com/ajax/services/search/web?v=1.0'
referer='http://code.google.com/p/goosh-4-linux/'
num=4
api='custom'
switch=
INI
)))
    throw new gooshException('could not create ini file');
    
    exit('goosh successfully installed. Type `goosh` to begin using it. Happy searching :)'.PHP_EOL);
  }
}
